#include <iostream>
#include <vector>

using std::cout;
using std::cin;
using std::endl;
using std::vector;
void print(const vector<int> & num)
{
    cout << "num'size :" << num.size() << endl;
    cout << "num'capacity :" << num.capacity() << endl;
}
int main()
{
    long arr[5] = {1,2,3,4,5};
    vector<int> numbers;
    print(numbers);
    numbers.reserve(10);
    for(size_t  x = 0;x < numbers.size(); x++)
    {
        cout << numbers[x] << " ";
    }
    cout << endl;
    print(numbers);
    cout << "num is empty ? " <<numbers.empty() << endl; 
    //存放10个0
    vector <long> number(4);
    for(size_t  x = 0;x < number.size(); x++)
    {
        cout << number[x] << " ";
    }
    cout << endl;
    //存放10个5
    vector<int> number1(4,5);
    for(auto & i : number1)
    {
        cout << i << " ";
    }
    cout << endl;
    number1.push_back(6);
    for(auto & i : number1)
    {
        cout << i << " ";
    }
    cout << endl;
    //通过迭代器方式初始化vector对象
    // [ ) 左开右闭 正好是数组的长度size
    vector <long> number2(arr, arr+5);
    //定义在 std::vector<long> 类的内部。由于 vector 属于 std 命名空间，
    //因此必须通过作用域限定符 :: 明确指定其所属的命名空间和类。
    vector<long>::iterator it = number2.begin();
    while(it <number2.end())
    {
        cout << *it << " ";
        it++;
    }
    cout << endl;

    number2.pop_back();
    vector<long>::iterator it1 = number2.begin();
    while(it1 <number2.end())
    {
        cout << *it1 << " ";
        it1++;
    }
    cout << endl;
    number1.clear();
    print(number1);
    number1.shrink_to_fit();
    print(number1);
    return 0;
}